import { createApp } from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import './assets/global.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import axios from 'axios'
import router from './router'
import store from './store'


const app = createApp(App)
// 定义特性标志
// window.__VUE_PROD_DEVTOOLS__ = false;
// window.__VUE_PROD_HYDRATION_MISMATCH_DETAILS__ = false;

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
  }
app.config.globalProperties.$axios=axios
app.config.globalProperties.$httpUrl="http://localhost:8090"
const debounce = (fn, delay) => {
  let timer = null;
  return function () {
    let context = this;
    let args = arguments;
    clearTimeout(timer);
    timer = setTimeout(function () {
      fn.apply(context, args);
    }, delay);
  }
}

const _ResizeObserver = window.ResizeObserver;
window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
  constructor(callback) {
    callback = debounce(callback, 16);
    super(callback);
  }
}
async function init(){
  if(window.sessionStorage.getItem('User')){
      console.log('我先')
      await  store.dispatch('updateMenu',store.state.menu)
      console.log('main.js')
      console.log(router)
      console.log(store.state.menu)
      console.log('初始化完成')
      
  }
}
async function call(){
  await init()
  app.use(router).use(store).use(ElementPlus).mount('#app')
}
call()
